#![no_std]
#![no_main]
#![test_runner(test)]
#![feature(custom_test_frameworks)]
extern crate alloc;

use alloc::string::{String, ToString};
use core::alloc::GlobalAlloc;
use core::arch::global_asm;

mod rom_uart;
mod firm;
mod alc;

#[global_allocator]
static allc() {

}


fn say(arg : &String){
    for c in (arg.chars()){
        unsafe {
            rom_uart::uart_tx_one_char(*(&c) as u8);
        }
    }
}

#[unsafe(no_mangle)]
#[allow(dead_code)]
extern "C" fn main() {
    let i = "hello world. and I have a lot words(32bits) to say!\r\n";
    let mut magf = 123;
    let magf_max = 1234567;

    loop{

        say(&i.to_string());
        say(&magf.to_string());

        unsafe{
            rom_uart::uart_tx_one_char(0);
        }

        for _i in 2..1999999 {
            magf = (magf * 3 + 5) % magf_max;
        }
    }
}

//TODO: ISSUE: flash program will be damaged when reset happens.

